/**************************************************************************
 * $Date : 2014/12/11$
 * $Author Hlaing Win Tun $
 * $Version : 1.0 $
 * Copyright (c) 2014 HLAING WIN TUN.
 *************************************************************************/
package com.hwt.main;

import java.io.BufferedReader;
import java.io.FileReader;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

import org.joda.time.DateTimeConstants;
import org.joda.time.LocalDate;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;

public class Main {

	public static void main(String[] args) {
		// SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
		// String date = sdf.format(new Date());
		// System.out.println(date);
		// long week = System.currentTimeMillis() + 518400000;
		// sdf = new SimpleDateFormat("MMdd");
		// Date d = new Date();
		// Calendar cal = new GregorianCalendar(2014, 1, 1);
		// String date22 = sdf.format(new Date(week));
		// System.out.println(date22);
		// System.out.println(date + "-" + date22); //15/10/2013
		// String a = "abc";
		// a.contains("a");

		Calendar c = new GregorianCalendar();
		// c.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
		// c.add(Calendar.DATE, 6);
		//
		// c.get(Calendar.MONDAY);
		// c.getFirstDayOfWeek();
		// ;
		LocalDate ld = new LocalDate();
		DateTimeFormatter format = DateTimeFormat.forPattern("yyyyMMdd");
		int year = ld.getYear();
		String month = DateTimeFormat.forPattern("MM").print(ld) + ". "
				+ DateTimeFormat.forPattern("MMM").print(ld);
		format.print(ld);

		LocalDate monday = ld.withDayOfWeek(DateTimeConstants.MONDAY);
		String folderName = DateTimeFormat.forPattern("yyyyMMdd").print(monday)
				+ "-"
				+ DateTimeFormat.forPattern("MMdd").print(monday.plusDays(6));
		System.out.println(monday);

		try {
			String line = "";
			String[] date = new String[3];
			int i = 0;
			int end = 0;
			int start = 0;
			BufferedReader file = new BufferedReader(new FileReader(
					"D:\\notify_report.bat"));
			while ((line = file.readLine()) != null) {
				System.out.println(line);
				end = line.length();
				for (int j = 0; j < 3; j++) {
					start = line.lastIndexOf("\\", end - 1);
					date[j] = line.substring(start + 1, end);
					end = start;
					if (date[j].intern() == "2014") {
						break;
					}
				}
				if (date[2].intern() == "2014") {
					if (date[1]
							.contains(String.valueOf(c.get(Calendar.MONTH) + 1))) {
						System.out
								.println(String.valueOf(c.get(Calendar.MONTH) + 1));
					}
				} else if (date[1].contains(String.valueOf(c
						.get(Calendar.MONTH)))) {

				}
			}

			file.close();
		} catch (Exception e) {
			System.out.println("Problem reading file.");
		}

	}
}
